home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / Dialogs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-20  |  14.1 KB  |  399 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        Dialogs.h
  3.  
  4.      Contains:    Dialog Manager interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0.1 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __DIALOGS__
  21. #define __DIALOGS__
  22.  
  23.  
  24. #ifndef __ERRORS__
  25. #include <Errors.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __MEMORY__
  30. #include <Memory.h>
  31. #endif
  32. /*    #include <Types.h>                                            */
  33. /*    #include <MixedMode.h>                                        */
  34.  
  35. #ifndef __WINDOWS__
  36. #include <Windows.h>
  37. #endif
  38. /*    #include <Quickdraw.h>                                        */
  39. /*        #include <QuickdrawText.h>                                */
  40. /*    #include <Events.h>                                            */
  41. /*        #include <OSUtils.h>                                    */
  42. /*    #include <Controls.h>                                        */
  43. /*        #include <Menus.h>                                        */
  44.  
  45. #ifndef __TEXTEDIT__
  46. #include <TextEdit.h>
  47. #endif
  48.  
  49. #ifndef __EVENTS__
  50. #include <Events.h>
  51. #endif
  52.  
  53. #ifdef __cplusplus
  54. extern "C" {
  55. #endif
  56.  
  57. #if PRAGMA_ALIGN_SUPPORTED
  58. #pragma options align=mac68k
  59. #endif
  60.  
  61. #if PRAGMA_IMPORT_SUPPORTED
  62. #pragma import on
  63. #endif
  64.  
  65.  
  66. enum {
  67.     ctrlItem                    = 4,
  68.     btnCtrl                        = 0,
  69.     chkCtrl                        = 1,
  70.     radCtrl                        = 2,
  71.     resCtrl                        = 3,
  72.     statText                    = 8,
  73.     editText                    = 16,
  74.     iconItem                    = 32,
  75.     picItem                        = 64,
  76.     userItem                    = 0,
  77.     itemDisable                    = 128,
  78.     ok                            = 1,
  79.     cancel                        = 2,
  80.     stopIcon                    = 0,
  81.     noteIcon                    = 1,
  82.     cautionIcon                    = 2
  83. };
  84.  
  85. /* new, more standard names for dialog item constants */
  86. enum {
  87.     kControlDialogItem = ctrlItem,
  88.     kButtonDialogItem = ctrlItem + btnCtrl,
  89.     kCheckBoxDialogItem = ctrlItem + chkCtrl,
  90.     kRadioButtonDialogItem = ctrlItem + radCtrl,
  91.     kResourceControlDialogItem = ctrlItem + resCtrl,
  92.     kStaticTextDialogItem = statText,
  93.     kEditTextDialogItem = editText,
  94.     kIconDialogItem = iconItem,
  95.     kPictureDialogItem = picItem,
  96.     kUserDialogItem = userItem,
  97.     kItemDisableBit = itemDisable,
  98.     kStdOkItemIndex = ok,
  99.     kStdCancelItemIndex = cancel,
  100.     kStopIcon = stopIcon,
  101.     kNoteIcon = noteIcon,
  102.     kCautionIcon = cautionIcon
  103. };
  104.  
  105. #if OLDROUTINENAMES
  106. enum {
  107.     kOkItemIndex = kStdOkItemIndex,
  108.     kCancelItemIndex = kStdCancelItemIndex
  109. };
  110. #endif 
  111.  
  112. typedef short DITLMethod;
  113.  
  114.  
  115. enum {
  116.     overlayDITL                    = 0,
  117.     appendDITLRight                = 1,
  118.     appendDITLBottom            = 2
  119. };
  120.  
  121. typedef short StageList;
  122.  
  123. typedef OSType DialogPropertyTag;
  124.  
  125. #if STRICT_WINDOWS
  126. typedef struct OpaqueDialogRef *DialogPtr;
  127.  
  128. typedef struct OpaqueDialogRef *DialogRef;
  129.  
  130. #else
  131. typedef WindowPtr DialogPtr;
  132.  
  133. typedef DialogPtr DialogRef;
  134.  
  135. #endif
  136. typedef pascal void (*SoundProcPtr)(short soundNumber);
  137. typedef pascal Boolean (*ModalFilterProcPtr)(DialogPtr theDialog, EventRecord *theEvent, short *itemHit);
  138. typedef pascal void (*UserItemProcPtr)(WindowPtr theWindow, short itemNo);
  139.  
  140. #if GENERATINGCFM
  141. typedef UniversalProcPtr SoundUPP;
  142. typedef UniversalProcPtr ModalFilterUPP;
  143. typedef UniversalProcPtr UserItemUPP;
  144. #else
  145. typedef SoundProcPtr SoundUPP;
  146. typedef ModalFilterProcPtr ModalFilterUPP;
  147. typedef UserItemProcPtr UserItemUPP;
  148. #endif
  149.  
  150. enum {
  151.     uppSoundProcInfo = kPascalStackBased
  152.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short))),
  153.     uppModalFilterProcInfo = kPascalStackBased
  154.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  155.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DialogPtr)))
  156.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(EventRecord*)))
  157.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short*))),
  158.     uppUserItemProcInfo = kPascalStackBased
  159.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(WindowPtr)))
  160.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  161. };
  162.  
  163. #if GENERATINGCFM
  164. #define NewSoundProc(userRoutine)        \
  165.         (SoundUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSoundProcInfo, GetCurrentArchitecture())
  166. #define NewModalFilterProc(userRoutine)        \
  167.         (ModalFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppModalFilterProcInfo, GetCurrentArchitecture())
  168. #define NewUserItemProc(userRoutine)        \
  169.         (UserItemUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppUserItemProcInfo, GetCurrentArchitecture())
  170. #else
  171. #define NewSoundProc(userRoutine)        \
  172.         ((SoundUPP) (userRoutine))
  173. #define NewModalFilterProc(userRoutine)        \
  174.         ((ModalFilterUPP) (userRoutine))
  175. #define NewUserItemProc(userRoutine)        \
  176.         ((UserItemUPP) (userRoutine))
  177. #endif
  178.  
  179. #if GENERATINGCFM
  180. #define CallSoundProc(userRoutine, soundNumber)        \
  181.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSoundProcInfo, (soundNumber))
  182. #define CallModalFilterProc(userRoutine, theDialog, theEvent, itemHit)        \
  183.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppModalFilterProcInfo, (theDialog), (theEvent), (itemHit))
  184. #define CallUserItemProc(userRoutine, theWindow, itemNo)        \
  185.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppUserItemProcInfo, (theWindow), (itemNo))
  186. #else
  187. #define CallSoundProc(userRoutine, soundNumber)        \
  188.         (*(userRoutine))((soundNumber))
  189. #define CallModalFilterProc(userRoutine, theDialog, theEvent, itemHit)        \
  190.         (*(userRoutine))((theDialog), (theEvent), (itemHit))
  191. #define CallUserItemProc(userRoutine, theWindow, itemNo)        \
  192.         (*(userRoutine))((theWindow), (itemNo))
  193. #endif
  194.  
  195. #if ! STRICT_WINDOWS
  196. struct DialogRecord {
  197.     WindowRecord                    window;
  198.     Handle                            items;
  199.     TEHandle                        textH;
  200.     short                            editField;
  201.     short                            editOpen;
  202.     short                            aDefItem;
  203. };
  204. typedef struct DialogRecord DialogRecord;
  205.  
  206. typedef DialogRecord *DialogPeek;
  207.  
  208. #endif
  209. struct DialogTemplate {
  210.     Rect                            boundsRect;
  211.     short                            procID;
  212.     Boolean                            visible;
  213.     Boolean                            filler1;
  214.     Boolean                            goAwayFlag;
  215.     Boolean                            filler2;
  216.     long                            refCon;
  217.     short                            itemsID;
  218.     Str255                            title;
  219. };
  220. typedef struct DialogTemplate DialogTemplate;
  221.  
  222. typedef DialogTemplate *DialogTPtr, **DialogTHndl;
  223.  
  224. struct AlertTemplate {
  225.     Rect                            boundsRect;
  226.     short                            itemsID;
  227.     StageList                        stages;
  228. };
  229. typedef struct AlertTemplate AlertTemplate;
  230.  
  231. typedef AlertTemplate *AlertTPtr, **AlertTHndl;
  232.  
  233. extern pascal void InitDialogs(void *ignored)
  234.  ONEWORDINLINE(0xA97B);
  235. extern pascal void ErrorSound(SoundUPP soundProc)
  236.  ONEWORDINLINE(0xA98C);
  237. extern pascal DialogRef NewDialog(void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short procID, WindowRef behind, Boolean goAwayFlag, long refCon, Handle itmLstHndl)
  238.  ONEWORDINLINE(0xA97D);
  239. extern pascal DialogRef GetNewDialog(short dialogID, void *dStorage, WindowRef behind)
  240.  ONEWORDINLINE(0xA97C);
  241. extern pascal void CloseDialog(DialogRef theDialog)
  242.  ONEWORDINLINE(0xA982);
  243. extern pascal void DisposeDialog(DialogRef theDialog)
  244.  ONEWORDINLINE(0xA983);
  245. extern pascal void ParamText(ConstStr255Param param0, ConstStr255Param param1, ConstStr255Param param2, ConstStr255Param param3)
  246.  ONEWORDINLINE(0xA98B);
  247. extern pascal void ModalDialog(ModalFilterUPP modalFilter, short *itemHit)
  248.  ONEWORDINLINE(0xA991);
  249. extern pascal Boolean IsDialogEvent(const EventRecord *theEvent)
  250.  ONEWORDINLINE(0xA97F);
  251. extern pascal Boolean DialogSelect(const EventRecord *theEvent, DialogRef *theDialog, short *itemHit)
  252.  ONEWORDINLINE(0xA980);
  253. extern pascal void DrawDialog(DialogRef theDialog)
  254.  ONEWORDINLINE(0xA981);
  255. extern pascal void UpdateDialog(DialogRef theDialog, RgnHandle updateRgn)
  256.  ONEWORDINLINE(0xA978);
  257. extern pascal short Alert(short alertID, ModalFilterUPP modalFilter)
  258.  ONEWORDINLINE(0xA985);
  259. extern pascal short StopAlert(short alertID, ModalFilterUPP modalFilter)
  260.  ONEWORDINLINE(0xA986);
  261. extern pascal short NoteAlert(short alertID, ModalFilterUPP modalFilter)
  262.  ONEWORDINLINE(0xA987);
  263. extern pascal short CautionAlert(short alertID, ModalFilterUPP modalFilter)
  264.  ONEWORDINLINE(0xA988);
  265. extern pascal void GetDialogItem(DialogRef theDialog, short itemNo, short *itemType, Handle *item, Rect *box)
  266.  ONEWORDINLINE(0xA98D);
  267. extern pascal void SetDialogItem(DialogRef theDialog, short itemNo, short itemType, Handle item, const Rect *box)
  268.  ONEWORDINLINE(0xA98E);
  269. extern pascal void HideDialogItem(DialogRef theDialog, short itemNo)
  270.  ONEWORDINLINE(0xA827);
  271. extern pascal void ShowDialogItem(DialogRef theDialog, short itemNo)
  272.  ONEWORDINLINE(0xA828);
  273. extern pascal void SelectDialogItemText(DialogRef theDialog, short itemNo, short strtSel, short endSel)
  274.  ONEWORDINLINE(0xA97E);
  275. extern pascal void GetDialogItemText(Handle item, Str255 text)
  276.  ONEWORDINLINE(0xA990);
  277. extern pascal void SetDialogItemText(Handle item, ConstStr255Param text)
  278.  ONEWORDINLINE(0xA98F);
  279. extern pascal short FindDialogItem(DialogRef theDialog, Point thePt)
  280.  ONEWORDINLINE(0xA984);
  281. extern pascal DialogRef NewColorDialog(void *dStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short procID, WindowRef behind, Boolean goAwayFlag, long refCon, Handle items)
  282.  ONEWORDINLINE(0xAA4B);
  283. extern pascal short GetAlertStage( void )
  284.     TWOWORDINLINE( 0x3EB8, 0x0A9A ); /* MOVE.w $0A9A,(SP) */
  285. extern DialogRef newdialog(void *wStorage, const Rect *boundsRect, const char *title, Boolean visible, short procID, WindowRef behind, Boolean goAwayFlag, long refCon, Handle itmLstHndl);
  286. extern DialogRef newcolordialog(void *dStorage, const Rect *boundsRect, const char *title, Boolean visible, short procID, WindowRef behind, Boolean goAwayFlag, long refCon, Handle items);
  287. extern pascal void ResetAlertStage(void)
  288.  TWOWORDINLINE(0x4278, 0x0A9A);
  289. extern pascal void DialogCut(DialogRef theDialog);
  290. extern pascal void DialogPaste(DialogRef theDialog);
  291. extern pascal void DialogCopy(DialogRef theDialog);
  292. extern pascal void DialogDelete(DialogRef theDialog);
  293. extern pascal void SetDialogFont( short value )
  294.     TWOWORDINLINE( 0x31DF, 0x0AFA ); /* MOVE.w (SP)+,$0AFA */
  295. #if CGLUESUPPORTED
  296. extern void paramtext(const char *param0, const char *param1, const char *param2, const char *param3);
  297. extern void getdialogitemtext(Handle item, char *text);
  298. extern void setdialogitemtext(Handle item, const char *text);
  299. extern short finddialogitem(DialogRef theDialog, Point *thePt);
  300. #endif
  301. extern pascal void AppendDITL(DialogRef theDialog, Handle theHandle, DITLMethod method);
  302. extern pascal short CountDITL(DialogRef theDialog);
  303. extern pascal void ShortenDITL(DialogRef theDialog, short numberItems);
  304. extern pascal Boolean StdFilterProc(DialogRef theDialog, EventRecord *event, short *itemHit);
  305. extern pascal OSErr GetStdFilterProc(ModalFilterUPP *theProc)
  306.  THREEWORDINLINE(0x303C, 0x0203, 0xAA68);
  307. extern pascal OSErr SetDialogDefaultItem(DialogRef theDialog, short newItem)
  308.  THREEWORDINLINE(0x303C, 0x0304, 0xAA68);
  309. extern pascal OSErr SetDialogCancelItem(DialogRef theDialog, short newItem)
  310.  THREEWORDINLINE(0x303C, 0x0305, 0xAA68);
  311. extern pascal OSErr SetDialogTracksCursor(DialogRef theDialog, Boolean tracks)
  312.  THREEWORDINLINE(0x303C, 0x0306, 0xAA68);
  313. #if OLDROUTINENAMES
  314. #if !GENERATINGCFM
  315. extern pascal void CouldDialog(short dialogID)
  316.  ONEWORDINLINE(0xA979);
  317. extern pascal void FreeDialog(short dialogID)
  318.  ONEWORDINLINE(0xA97A);
  319. extern pascal void CouldAlert(short alertID)
  320.  ONEWORDINLINE(0xA989);
  321. extern pascal void FreeAlert(short alertID)
  322.  ONEWORDINLINE(0xA98A);
  323. #endif
  324. #define DisposDialog(theDialog) DisposeDialog(theDialog)
  325. #define UpdtDialog(theDialog, updateRgn) UpdateDialog(theDialog, updateRgn)
  326. #define GetDItem(theDialog, itemNo, itemType, item, box)  \
  327.     GetDialogItem(theDialog, itemNo, itemType, item, box)
  328. #define SetDItem(theDialog, itemNo, itemType, item, box)  \
  329.     SetDialogItem(theDialog, itemNo, itemType, item, box)
  330. #define HideDItem(theDialog, itemNo) HideDialogItem(theDialog, itemNo)
  331. #define ShowDItem(theDialog, itemNo) ShowDialogItem(theDialog, itemNo)
  332. #define SelIText(theDialog, itemNo, strtSel, endSel)  \
  333.     SelectDialogItemText(theDialog, itemNo, strtSel, endSel)
  334. #define GetIText(item, text) GetDialogItemText(item, text)
  335. #define SetIText(item, text) SetDialogItemText(item, text)
  336. #define FindDItem(theDialog, thePt) FindDialogItem(theDialog, thePt)
  337. #define NewCDialog(dStorage, boundsRect, title, visible, procID, behind, goAwayFlag, refCon, items)  \
  338.     NewColorDialog(dStorage, boundsRect, title, visible, procID, behind,  \
  339.     goAwayFlag, refCon, items)
  340. #define GetAlrtStage() GetAlertStage()
  341. #define ResetAlrtStage() ResetAlertStage()
  342. #define DlgCut(theDialog) DialogCut(theDialog)
  343. #define DlgPaste(theDialog) DialogPaste(theDialog)
  344. #define DlgCopy(theDialog) DialogCopy(theDialog)
  345. #define DlgDelete(theDialog) DialogDelete(theDialog)
  346. #define SetDAFont(fontNum) SetDialogFont(fontNum)
  347. #if CGLUESUPPORTED
  348. #define newcdialog(dStorage, boundsRect, title, visible, procID, behind, goAwayFlag, refCon, items)  \
  349.     newcolordialog(dStorage, boundsRect, title, visible, procID, behind,  \
  350.     goAwayFlag, refCon, items)
  351. #define getitext(item, text) getdialogitemtext(item, text)
  352. #define setitext(item, text) setdialogitemtext(item, text)
  353. #define findditem(theDialog, thePt) finddialogitem(theDialog, thePt)
  354. #endif
  355. #else
  356. #endif
  357.  
  358. /*####################################################################################
  359.  
  360.      Dialog Accessors
  361.  
  362.     Use these with or without STRICT_WINDOWS and your source will more easily migrate
  363.     to being Copland-savvy.  When STRICT_WINDOWS is set to true, the DialogRecord and
  364.     DialogPeek are no longer defined.  This will allow you to, from a source code level, 
  365.     remove all direct accesses to Dialog Manager data structures.
  366.  
  367.     These accessors will be available as true API entrypoints in Copland.
  368.  
  369.     If you don't see an accessor for a field you need, there's probably a very good
  370.     reason.  Needing access to fields for which there is no accessor is a good indicator
  371.     of behavior that is not Copland-savvy.  Such behavior does not necessarily make your 
  372.     code incompatible, but it likely something we are trying to discourage as we evolve
  373.     the toolbox into a more robust and useful service.
  374.  
  375.     Please direct all questions regarding usage to the TOOLBOX AppleLink address.
  376.  
  377. #####################################################################################*/
  378.  
  379. #define GetDialogWindow(dialog) ((WindowRef) dialog)
  380. #define GetDialogDefaultItem(dialog) (*(SInt16 *) (((UInt8 *) dialog) + 168))
  381. #define GetDialogCancelItem(dialog) (*(SInt16 *) (((UInt8 *) dialog) + 166))
  382. #define GetDialogKeyboardFocusItem(dialog) ((*(SInt16 *) (((UInt8 *) dialog) + 164)) < 0 ?  \
  383.     -1 : (*(SInt16 *) (((UInt8 *) dialog) + 164)) + 1)
  384. #define SetGrafPortOfDialog(dialog) do { SetPort ((GrafPtr) dialog); } while (false);
  385.  
  386. #if PRAGMA_IMPORT_SUPPORTED
  387. #pragma import off
  388. #endif
  389.  
  390. #if PRAGMA_ALIGN_SUPPORTED
  391. #pragma options align=reset
  392. #endif
  393.  
  394. #ifdef __cplusplus
  395. }
  396. #endif
  397.  
  398. #endif /* __DIALOGS__ */
  399.